//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
#ifndef __BOOT_COMMON_H
#define __BOOT_COMMON_H

#ifdef __cplusplus
extern "C" {
#endif

//------------------------------------------------------------------------------

enum BOOT_POWERON_TYPE {
    BOOT_POWERON_UNKNOWN = 0,
    BOOT_POWERON_ONBUTTON = 1,
    BOOT_POWERON_RESET = 2,
    BOOT_POWERON_AC_CHARGER = 3,
    BOOT_POWERON_USB_HOST = 5,
    BOOT_POWERON_USB_CHARGER_1 = 6,
    BOOT_POWERON_USB_CHARGER_2 = 7,
    BOOT_POWERON_OEM = 0x80000000,
    BOOT_POWERON_FAILURE = -1
};

// OEMBootHardwareInit function is called to initialize hardware.
// It returns power-on type detected.
UINT32
OEMBootHardwareInit(
    );

// OEMBootCharge function is called to charge battery. It returns
// power-on type detected (same as OEMBootHardwareInit).
UINT32
OEMBootCharge(
    UINT32 source,
    UINT32 current
    );

// OEMBootPowerOff function power-off device. No return expected.
VOID
OEMBootPowerOff(
    );


//------------------------------------------------------------------------------

enum BOOT_DEVICE_CLASS {
    BOOT_DEVICE_CLASS_STORE     = 1,
    BOOT_DEVICE_CLASS_DISPLAY   = 2,
    BOOT_DEVICE_CLASS_KEYPAD    = 3,
    BOOT_DEVICE_CLASS_BATTERY   = 4,
    BOOT_DEVICE_CLASS_LED       = 5,
};

HANDLE
OEMBootGetDeviceHandle(
    UINT32 deviceClass,
    UINT32 deviceIndex
    );

VOID
OEMBootReleaseDeviceHandle(
    HANDLE hDevice
    );

//------------------------------------------------------------------------------

__inline
HANDLE
BootStoreGetHandle(
    UINT32 index
    )
{
    return OEMBootGetDeviceHandle(BOOT_DEVICE_CLASS_STORE, index);
}

//------------------------------------------------------------------------------

__inline
VOID
BootStoreReleaseHandle(
    HANDLE hStore
    )
{
    OEMBootReleaseDeviceHandle(hStore);
}

//------------------------------------------------------------------------------

__inline
HANDLE
BootDisplayGetHandle(
    UINT32 index
    )
{
    return OEMBootGetDeviceHandle(BOOT_DEVICE_CLASS_DISPLAY, index);
}

//------------------------------------------------------------------------------

__inline
VOID
BootDisplayReleaseHandle(
    HANDLE hDisplay
    )
{
    OEMBootReleaseDeviceHandle(hDisplay);
}

//------------------------------------------------------------------------------

__inline
HANDLE
BootKeypadGetHandle(
    UINT32 index
    )
{
    return OEMBootGetDeviceHandle(BOOT_DEVICE_CLASS_KEYPAD, index);
}

//------------------------------------------------------------------------------

__inline
VOID
BootKeypadReleaseHandle(
    HANDLE hKeypad
    )
{
    OEMBootReleaseDeviceHandle(hKeypad);
}

//------------------------------------------------------------------------------

__inline
HANDLE
BootBatteryGetHandle(
    UINT32 index
    )
{
    return OEMBootGetDeviceHandle(BOOT_DEVICE_CLASS_BATTERY, index);
}

//------------------------------------------------------------------------------

__inline
VOID
BootBatteryReleaseHandle(
    HANDLE hBattery
    )
{
    OEMBootReleaseDeviceHandle(hBattery);
}

//------------------------------------------------------------------------------

__inline
HANDLE
BootLedGetHandle(
    UINT32 index
    )
{
    return OEMBootGetDeviceHandle(BOOT_DEVICE_CLASS_LED, index);
}

//------------------------------------------------------------------------------

__inline
VOID
BootLedReleaseHandle(
    HANDLE hLed
    )
{
    OEMBootReleaseDeviceHandle(hLed);
}

//------------------------------------------------------------------------------

#ifdef __cplusplus
}
#endif

#endif // __BOOT_COMMON_H
